When a signal is processed, generally the signal may be divided into multiple vectors. For example, referring to FIG. 1, the signal sampling is classified, several sampling values are classified as a group, which may be referred to as a vector, and the number of this group of sampling values is referred to as the dimension of the vector. In a voice encoder based on a code excited linear prediction (CELP) model, generally several pulses are used to denote quasi-white noise excitation. In order to reduce the complexity of the encoder, generally an input signal is divided into several sub-frames to be processed, and during processing a fixed code book, generally a signal of each sub-frame is further divided into several tracks. Based on the foregoing understanding about the vector, it may be regarded that sampling points on a track may form a multi-dimensional vector. For example, for a track having sixteen positions, it is assumed that a signal sampling case on a track is described using a pulse, and a value may be represented as [−1, −5, 0, −5, 12, 0, . . . , 0]. From the perspective of the pulse, it is denoted that this track has four non-zero pulses, that is, a first position has a pulse with amplitude being 1, and a symbol being “−”; a second position has a pulse with amplitude being 5, and a symbol being “−”; a third position has a pulse with amplitude being zero, and the rest may be deduced by analogy. From the perspective of the vector, a 16-dimensional vector has four non-zero components.
It is well-known that, in the voice encoding field, a voice encoder based on the CELP model is applied very widely, such as G.729, Global System for Mobile Communications (GSM) and G.723.1, which are already widely applied in various digital signal processors (DSP), embedded devices, mobile phones and personal computers (PC). Compared with other types of voice encoders, the voice encoder/decoder based on the CELP model can achieve good voice quality in a case of an extremely low code rate, and still have excellent performance in a case of a high code rate.
In the vector encoding technology, usually an algebraic code book is used to perform quantization encoding on a residual signal after adaptive filtering. After information of a position and a symbol of an optimal algebraic code book pulse on a track is obtained through searching, a corresponding index value is obtained through encoding calculation, so that a decoding end can reestablish a pulse sequence according to the index value. Under the premise of ensuring lossless reestablishment, to reduce bits, which are needed for an encoding index value, as much as possible is one of main objectives of the research and development of an algebraic code book pulse encoding method.
The following takes an example of a preferable encoding method in voice encoding an adaptive multi-rate wideband (AMR_WB+) encoding method, to introduce a specific encoding method adopted for an existing algebraic code book pulse. According to the difference between encoding code rates, 1 to N pulses may be encoded on each track, and it is assumed that each track has M=2m positions, and procedures for encoding one to six pulses on each track in AMR_WB+ are respectively described as follows.
(1) One pulse is encoded on each track.
Because each track has 2m positions, a position index of a pulse on each track needs to be encoded with m bits, and a symbol index of the pulse needs to be encoded with 1 bit. An index value for encoding one pulse with a symbol is I1p(m)=p+s×2m, where pε[0, 2m−1] is a position index of the pulse; s is a symbol index of the pulse, and when a symbol of the pulse is positive, s is set to 0, and when the symbol of the pulse is negative, s is set to 1; I1pε[0, 2m+1−1].
The number of bits needed for encoding one pulse on each track is m+1.
(2) Two pulses are encoded on each track
According to a result of (1), m+1 bits are needed for encoding one pulse on each track, and m bits are needed for encoding a position index of another pulse; because the pulse order is not particularly needed, a symbol of another pulse may be denoted through a size relationship obtained by arranging position indexes of the pulses. An index value for encoding two pulses is I2p(m)=p1+I1p0×2m=p1+p0×2m+s×22m, where p0 and p1 E [0, 2m−1] are position indexes of two pulses, respectively; s is a symbol index of pulse p0; a specific denotation rule for a symbol of pulse p1 is p0<p1 denotes that symbols of the two pulses are the same, and p0>p1 denotes that the symbols of the two pulses are opposite; I2p E [0, 22m+1−1].
The number of bits needed for encoding two pulses on each track is 2m+1.
(3) Three pulses are encoded on each track.
Each track is divided into two sections, Section A and Section B, and each section includes 2m−1 positions. A certain section at least includes two pulses, and according to a result of (2), 2×(m−1)+1=2m−1 bits are needed for encoding the section; another pulse searches on the entire track, and according to a result of (1), m+1 bits are needed; furthermore, one bit is further needed to indicate a section including two pulses. An index value for encoding three pulses is I3p(m)=I2p(m−1)+k×22m−1+I1p(m)×22m, where k is an index of Section; I3pε[0, 23m+1−1].
The number of bits needed for encoding three pulses on each track is 3m+1.
(4) Four pulses are encoded on each track.
Each track is divided into two sections, Section A and Section B, and each section includes 2m−1 positions. Cases of combinations of the numbers of pulses included in each section are shown in the following table:
Number of pulses inNumber of pulses inNumber ofTypeSection ASection Bbits needed0044m−31134m−22224m−23314m−24404m−3
In the above table, the basis of the number of bits needed, which correspond to each type is that, for type 0 and type 4, a method similar to (4) is adopted in a section having four pulses, but the number of pulses for performing whole searching is two, it is equivalent to I2p(m−2)+k×22m−3+I2p(m−1)×22m−2; for type 1, it is equivalent to I1p(m−1)+I3p(m−1)×2m; for type 2, it is equivalent to I2p(m−1)+I2p(m−1)×22m−1; and for type 3, it is equivalent to I3p(m−1)+I1p(m−1)×23m−2.
Type 0 and type 4 are regarded as a kind of possible case, type 1 to type 3 each are used as a case, and totally there are four cases; therefore, two bits are needed to denote a corresponding case, thus type 1 to type 3 all need 4m−2+2=4m bits; moreover, for the case including type 0 and type 4, one bit is further needed for distinguishing, and therefore, type 0 and type 4 need 4m−3+2+1=4m bits.
The number of bits needed for encoding four pulses on each track is 4m.
(5) Five pulses are encoded on each track.
Each track is divided into two sections, Section A and Section B, and each section includes 2m−1 positions. A certain section at least includes three pulses, and according to a result of (3), 3×(m−1)+1=3m−2 bits are needed for encoding the section; the rest two pulses search on the entire track, and according to a result of (2), 2m+1 bits are needed; furthermore, one bit is further needed to indicate a section including three pulses. An index value for encoding five pulses is I5p(m)=I3p(m−1)+k×23m−2+I1p (m)×23m−1.
The number of bits needed for encoding five pulses on each track is 5m.
(6) Six pulses are encoded on each track.
Each track is divided into two sections, Section A and Section B, and each section includes 2m−1 positions. Cases of combinations of the numbers of pulses included in each section are shown in the following table:
Number of pulsesNumber of pulsesNumber ofTypein Section Ain Section Bbits needed0066m−51156m−52246m−53336m−44426m−55516m−56606m−5
In the above table, the basis of the number of bits needed, which correspond to each type, may be deduced following (4), and is not repeated again.
Type 0 and type 6, type 1 and type 5, type 2 and type 4 each are regarded as a possible case, type 3 is used as a case independently, and totally there are four cases; therefore, two bits are needed to denote a corresponding case, and type 3 needs 6m−4+2=6m−2 bits; for those cases including a combined type, one bit is further needed for distinguishing, and therefore, other types except for type 3 require 6m−5+2+1=6m−2 bits.
The number of bits needed for encoding six pulses on each track is 6m−2.
In the process of proposing the present invention, it is found that, In the algebraic pulse encoding method provided by AMR_WB+, an encoding logic similar to recursion is adopted to split a case of encoding a large number of pulses into several cases of encoding a small number of pulses for processing, in which the calculation complexity is large, and meanwhile, with the increase of the number of pulses encoded on a track, the redundancy of an encoding index is gradually accumulated, thereby easily causing waste of encoding bits.